package com.nars.reflection;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class ReflectionDemo {
	public static void main(String[] args) throws InstantiationException, IllegalAccessException {
		Object object = new Object();
		Class clazz = Test.class;
		Class clazzz = new Test().getClass().asSubclass(clazz);
//		System.out.println(clazzz.getClass().asSubclass());
		System.out.println(Boolean.TYPE);
		System.out.println(boolean[].class);
		System.out.println(boolean[].class.getName());
		System.out.println(boolean[].class.getSuperclass().getName());
		System.out.println("Interfaces:");
		System.out.println(boolean[].class.getSuperclass().getInterfaces());
		System.out.println(Boolean[].class);
		System.out.println(boolean[].class.getComponentType());
		System.out.println(Boolean[].class.getComponentType());
		
		System.out.println(Boolean[].class.isAnnotation());
		System.out.println(Boolean[].class.isInterface());
		System.out.println("Test:");
		System.out.println(Boolean[].class.isInstance(new Object()));
		System.out.println(object.getClass().isInstance(clazzz));
//		System.out.println(Boolean[].class.newInstance());
		
		
		//Fields
		Field[] fields = clazz.getDeclaredFields();
		System.out.println("Fields: ");
		//clazzz.
		for(Field f : fields) {
			System.out.println(f.getName() + "    " + f.getType());
		}
		
		
		//Methods
		Method[] methods = clazzz.getDeclaredMethods();
		System.out.println("Methods: ");
		for (Method f : methods) {
			System.out.println(f.getName() + "    " + f.getDefaultValue());
		}		
	}
}

